package com.jun.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;

import javax.servlet.http.Cookie;

@Slf4j
public class CookieUtil {

  public static String getToken(Cookie[] cookies, String target) {
    if (ObjectUtils.isEmpty(cookies)) {
      log.info("Cookie为空");
      return null;
    }

    for (Cookie cookie : cookies) {
      if ( target.equals(cookie.getName()) ) {
        log.info("cookie的key=" + cookie.getName());
        log.info("cookie的value=" + cookie.getValue());
        return cookie.getValue();
      }
    }
    return null;
  }

}
